import argparse
import os
import shutil
import subprocess

from .anki_backup_files import server_folder,local_folder

parser = argparse.ArgumentParser(description='Anki recovery program')

parser.add_argument('-email', metavar='email', type=str, help='Email address')
parser.add_argument('-date', metavar='date', type=str, help='Date')

args = parser.parse_args()

backup_folder=local_folder+"_bk"

print(args.email, args.date)

user_local_lolder = os.path.join(backup_folder, args.date) + "/syncserver/.syncserver"
user_local_lolder = os.path.join(user_local_lolder, args.email)

print(user_local_lolder)

assert os.path.exists(user_local_lolder), "不存在该备份！请尝试其他时间。"

subprocess.run(["rsync", "-avz", "--delete", user_local_lolder, server_folder])


